package com.matt.domain.nursery;

import com.matt.commons.model.Domain;
import com.matt.foundation.utils.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang.StringUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * *******************************
 * Created by lch.
 * form com.matt
 * on 2018/11/27
 * *******************************
 */
@Entity
@Table(name = "nursery_schedule_temp_record")
@Data
@EqualsAndHashCode(callSuper = true)
public class NurseryScheduleTempRecord extends Domain {

    @Column(columnDefinition = "varchar(32) COMMENT '托班模版Id'")
    private String nurseryScheduleTempId;

    @Column(columnDefinition = "varchar(500) COMMENT '活动名称'")
    private String activityContent;

    @Column(columnDefinition = "int default 0 COMMENT '分类 0:非主题课 1:主题课'")
    private Integer category=0;

    @Column(columnDefinition = " datetime COMMENT '开始时间' ")
    private Date beginDate;

    @Column(columnDefinition = " datetime COMMENT '结束时间' ")
    private Date endDate;
    
    @Column(columnDefinition = "varchar(500) COMMENT '如果是主题课程则存放主题课程ID,否则可能存放资源地址'")
    private String resObj;

    @Transient
    private String begin;

    @Transient
    private String end;

    public static NurseryScheduleTempRecord ofDomain(NurseryScheduleTemp temp, NurseryScheduleTempRecord tempRecord) {
        NurseryScheduleTempRecord vo = new NurseryScheduleTempRecord();
        vo.setNurseryScheduleTempId(temp.getId());
        vo.setActivityContent(tempRecord.getActivityContent());
        vo.setCategory(tempRecord.getCategory());
        vo.setBeginDate(DateUtil.parseToDayHourM(DateUtil.convertStr(new Date())+" "+tempRecord.getBegin()));
        vo.setEndDate(DateUtil.parseToDayHourM(DateUtil.convertStr(new Date())+" "+tempRecord.getEnd()));
        vo.setResObj(tempRecord.getResObj());
        return vo;
    }
}
